home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
CWPWindow.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
3KB
|
128 lines
// CWPWindow.cp
#ifndef CWPWindow_h
#include "CWPWindow.h"
#endif
#ifndef CWPApplication_h
#include "CWPApplication.h"
#endif
#ifndef ContextMaintainer_h
#include "ContextMaintainer.h"
#endif
#ifndef WindowDefinition_h
#include "WindowDefinition.h"
#endif
#ifndef Justification_h
#include "Justification.h"
#endif
#ifndef OSError_h
#include "OSError.h"
#endif
CWPWindow *CWPApplication::NewCWPWindow( const WindowInitializer& initializer )
{
ContextMaintainer cm( 0 );
return new CWPWindow( initializer );
}
void UpdateProject();
CWPWindow::CWPWindow( const WindowInitializer& initializer )
: Window( WindowDefinition::Document() ),
remainingText( Face::System() ),
remainingNumber( Face::System() ),
compiling( Face::System() ),
bar( progress ),
progressFrame( 1 ),
margin( PointObject( 23, 13 ), NamedColors::white ),
space1( 10 ),
space2( 10 ),
ear( watcher, *this, &CWPWindow::UpdateProgress )
{
remainingText.SetString( "\pFiles remaining to be compiled: " );
remainingNumber.SetHorizontalJustification( Justification::Trailing() );
remainingRow[0].SetView( remainingText );
remainingRow[1].SetView( remainingNumber );
progressFrame.Interior().SetView( bar );
column[0].SetView( remainingRow );
column[1].SetView( space1 );
column[2].SetView( compiling );
column[3].SetView( space2 );
column[4].SetView( progressFrame );
margin.Interior().SetView( column );
RootPane().SetView( margin );
UpdateProgress();
Initialize( initializer );
UpdateProject();
}
CWPWindow::~CWPWindow()
{
}
void CWPWindow::UpdateProgress()
{
remainingNumber.SetNumber( watcher.FilesLeft() );
String255 lineNumber;
NumToString( watcher.FileLine(), lineNumber );
if ( watcher.File().Length() == 0 )
compiling.Clear();
else
{
String255 compilingText( "\pCompiling “" );
compilingText += watcher.File();
compilingText += "\p” line ";
compilingText += lineNumber;
compiling.SetString( compilingText );
}
progress.Set( watcher.CompiledLines(), watcher.TotalLines() );
column.Update();
}
void UpdateProject()
{
OSType signature = 'CWIE';
AEAddressDesc address;
OSError error = AECreateDesc( typeApplSignature,
&signature,
sizeof( signature ),
&address );
error.Debug();
error.Throw();
AppleEvent event;
error = AECreateAppleEvent( 'MMPR',
'UpdP',
&address,
kAutoGenerateReturnID,
kAnyTransactionID,
&event );
error.Debug();
error.Throw();
AppleEvent reply;
error = AESend( &event,
&reply,
kAENoReply,
kAENeverInteract,
5 * 60 * 60,
0,
0 );
error.Debug();
error.Throw();
}